package com.wzy.floatactionbutton2;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    private FloatingActionButton mFloatingButton;
    private MyListView mListView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mListView = (MyListView) findViewById(R.id.list_view);
        mFloatingButton = (FloatingActionButton) findViewById(R.id.floating_button);
        mFloatingButton.setVisibility(View.VISIBLE);
        mFloatingButton.attachTo(mListView);
        mFloatingButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(MainActivity.this, "hahahhhahha", Toast.LENGTH_SHORT).show();
            }
        });
        mListView.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_expandable_list_item_1, getData()));
    }

    private List<String> getData() {

        List<String> data = new ArrayList<String>();
        for (int i = 0; i < 20; i++) {
            data.add("测试数据" + i);
        }


        return data;
    }
}
